package com.zeng.stpro.modules.app.controller;

import com.zeng.stpro.commons.controller.AbstractBaseController;
import com.zeng.stpro.commons.utils.Constant;
import com.zeng.stpro.commons.utils.R;
import com.zeng.stpro.modules.app.bean.SysMenu;
import com.zeng.stpro.modules.app.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.zeng.stpro.modules.security.utils.SecurityUtils.getUsername;


/**
 * @ClassName SysMenuController
 * @Description TODO
 * @Author zhijun zeng at 22:55 2021/2/3
 * @Version 1.0
 **/
@RestController
//@CrossOrigin
@RequestMapping(value = "/api/admin/menu")
public class SysMenuController extends AbstractBaseController {

    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping(value = "/nav")
    public R nav() {
        List<SysMenu> menuList = sysMenuService.findUserMenuListByUsername(getUsername());
        //List<String> permissionCodes = sysMenuService.findUserPermissionsByUsername
        return R.ok().data(Constant.LIST, menuList);
    }
}
